home *** CD-ROM | disk | FTP | other *** search
/ MacFormat 1994 November / macformat-018.iso / Demos / Extend 3.0 Demo / Demo Libraries / Demo Generic Lib / Demo Generic Lib.rsrc / MODL_31207_Multiply < prev    next >
Encoding:
Text File  |  1994-06-22  |  2.1 KB  |  68 lines

  1. real    timeArray[];
  2.  
  3. ** Multiplies the top input by the bottom.
  4. **    Copyright © 1989-1994 by Imagine That, Inc.
  5. **    All Rights Reserved.
  6. **    Extend Generic Library, Multiply block; Alfy Riddle
  7. **        modified     3/3/92    JSL modified for V2.0
  8. **                    3/10/94 DJK added block label to report & trace
  9.  
  10. procedure calc()
  11. {
  12.     ConOut = Con1In * Con2In;
  13.  
  14.     ** sysGlobal2 is the file reference number for the DEBUG TRACE
  15.     if( sysGlobal2 != 0.0 ) ** 0 is error, check for open file for TRACE
  16.         {
  17. // template for report:      |BLOCK NAME *****************|block number |BLOCK NUMBER*******
  18.         fileWrite(sysGlobal2,"Multiply                     block number "+(MyBlockNumber())+".  Current Time:"+currentTime+".","",True);
  19.         if(getBlockLabel(myBlockNumber()) != "")
  20.             fileWrite(sysGlobal2,"Block Label: "+getBlockLabel(myBlockNumber()),"",True);
  21.         fileWrite(sysGlobal2,"     Top Input = "+con1In,"",True);
  22.         fileWrite(sysGlobal2,"     Bot Input = "+con2In,"",True);
  23.         fileWrite(sysGlobal2,"     Output = "+conOut,"",True);
  24.         fileWrite(sysGlobal2," ","",True);
  25.         }
  26. }
  27.  
  28.  
  29. ** This message occurs for each step in the simulation.
  30. on Simulate
  31. {
  32.     calc();
  33. }
  34.  
  35.  
  36. ** If the dialog data is inconsistent for simulation, abort.
  37. on checkData
  38. {
  39.     sysGlobal1 = 0.0;    ** prevent false reports
  40.     sysGlobal2 = 0.0;    ** prevent false debugs
  41.     
  42.     ** at this point the connectors are 1 if used and 0 if not used.
  43.     if( !Con1In or !Con2In )
  44.         {
  45.         userError("Both Connectors must be used in Multiply, block number "+(MyBlockNumber()));
  46.         abort;
  47.         }
  48.  
  49.     if( getPassedArray(sysGlobal0, timeArray) )
  50.         getSimulateMsgs(FALSE);
  51. }
  52.  
  53.  
  54. on endSim
  55. {
  56.     ** sysGlobal1 is the file reference number for the TEXT REPORT
  57.     if( sysGlobal1 != 0.0 )  ** 0 is error, check for open file for REPORT
  58.         {
  59. // template for report:      |BLOCK NAME *****************|block number |BLOCK NUMBER*******
  60.         fileWrite(sysGlobal1,"Multiply                     block number "+MyBlockNumber(),"",True);
  61.         if(getBlockLabel(myBlockNumber()) != "")
  62.             fileWrite(sysGlobal1,"Block Label: "+getBlockLabel(myBlockNumber()),"",True);
  63.         if( comments != "" )
  64.             fileWrite(sysGlobal1,"     Comments = "+comments,"",True);        
  65.  
  66.         fileWrite(sysGlobal1," ","",True);    
  67.         }
  68. }